{literal}
<script type="text/javascript">
	$.ui.dialog.prototype.options.bgiframe = true;
	var progbar = "<img src='{/literal}{$GLOBALS.user_site_url}/system/ext/jquery/progbar.gif{literal}' />";
	var parentReload = false;
	function setParam(param, value, param2, value2)  {
		var formID = 'users_form';
		$("#" + formID + " #" + param).val(value);
		if (param2) {
			$("#" + formID + " #" + param2).val(value2);
		}
		formSubmit("{/literal}{$GLOBALS.site_url}/manage-{if $userGroupInfo.id == 'Employer' || $userGroupInfo.id == 'JobSeeker'}{$userGroupInfo.id|lower}s{else}{$userGroupInfo.id|lower}-users{/if}/{literal}", formID);
		return false; 
	}

	function chooseUser(username) {
		$('#username', window.parent.document).val(username);
		$("#messageBox").dialog("close");
		return false;
	}

	function chooseCustomer(user_sid) {
		$("#messageBox").dialog("close");
		location.href = "{/literal}{$GLOBALS.site_url}{literal}/add-invoice/?user_sid="+user_sid;
		return false;
	}
	</script>
{/literal}

<div class="clr"><br/></div>
<form method="post" name="users_form" id="users_form" >
	<input type="hidden" name="search_template" id="search_template" value="choose_user_search.tpl" />
	<input type="hidden" name="template" id="template" value="choose_user.tpl" />
	<input type="hidden" name="page" id="page" value="{$page}" />
	<input type="hidden" name="sorting_field" id="sorting_field" value="{$sorting_field}" />
	<input type="hidden" name="sorting_order" id="sorting_order" value="{$sorting_order}" />
	<input type="hidden" name="users_per_page" id="users_per_page" value="{$users_per_page}" />
	<input type="hidden" name="online" id="online" value="{$online}" />
	<input type="hidden" name="restore" value="1" />
    <div class="box" id="displayResults">
        <div class="box-header">
            <div class="resultsnumber"></div>
            <div class="pagination">
                {foreach from=$pages item=page}
                    {if $page == $currentPage}
                        <strong>{$page}</strong>
                    {else}
                        {if $page == $totalPages && $currentPage < $totalPages-3} ... {/if}
                        <a href="?page={$page}{if $sorting_field ne null}&amp;sorting_field={$sorting_field}{/if}{if $sorting_order ne null}&amp;sorting_order={$sorting_order}{/if}&amp;users_per_page={$users_per_page}{$searchFields}" onClick="return setParam('page', {$page}, false, false)">{$page}</a>
                        {if $page == 1 && $currentPage > 4} ... {/if}
                    {/if}
                {/foreach}
            </div>
            <div class="numberPerPage">
               [[per page]]:
                <select id="users_per_page" name="users_per_page" onchange="setParam('users_per_page', this.value, false, false);" class="perPage">
                    <option value="10" {if $users_per_page == 10}selected="selected"{/if}>10</option>
                    <option value="20" {if $users_per_page == 20}selected="selected"{/if}>20</option>
                    <option value="50" {if $users_per_page == 50}selected="selected"{/if}>50</option>
                    <option value="100" {if $users_per_page == 100}selected="selected"{/if}>100</option>
                </select>
            </div>
        </div>
        <div class="innerpadding">
            <div id="displayResultsTable">
                <table width="100%">
                    <thead>
                        <tr>
                            <th>
                                <a href="?restore=1&amp;sorting_field=sid&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'sid'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'sid', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'sid'}DESC{else}ASC{/if}')">[[ID]]</a>
                                {if $sorting_field == 'sid'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                            <th>
                                <a href="?restore=1&amp;sorting_field=username&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'username'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'username', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'username'}DESC{else}ASC{/if}')">[[Username]]</a>
                                {if $sorting_field == 'username'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                            {if $userGroupInfo.id == 'Employer'}
                            	<th>
	                                <a href="?restore=1&amp;sorting_field=CompanyName&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'CompanyName'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'CompanyName', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'CompanyName'}DESC{else}ASC{/if}')">[[Company Name]]</a>
	                                {if $sorting_field == 'CompanyName'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
	                            </th>
                            {elseif $userGroupInfo.id == 'JobSeeker'}
                            	<th>
	                                <a href="?restore=1&amp;sorting_field=FirstName&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'FirstName'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'FirstName', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'FirstName'}DESC{else}ASC{/if}')">[[First Name]]</a>
	                                {if $sorting_field == 'FirstName'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
	                            </th>
	                            <th>
	                                <a href="?restore=1&amp;sorting_field=LastName&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'LastName'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'LastName', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'LastName'}DESC{else}ASC{/if}')">[[Last Name]]</a>
	                                {if $sorting_field == 'LastName'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
	                            </th>
                            {/if}
                            <th>
                                <a href="?restore=1&amp;sorting_field=email&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'email'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'email', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'email'}DESC{else}ASC{/if}')">[[Email]]</a>
                                {if $sorting_field == 'email'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                            <th>Products</th>
                            <th>
                                <a href="?restore=1&amp;sorting_field=registration_date&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'registration_date'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'registration_date', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'registration_date'}DESC{else}ASC{/if}')">[[Registration Date]]</a>
                                {if $sorting_field == 'registration_date'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                            <th>
                                <a href="?restore=1&amp;sorting_field=active&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'active'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'active', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'active'}DESC{else}ASC{/if}')">[[Status]]</a>
                                {if $sorting_field == 'active'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                        	{if $ApproveByAdminChecked}
                            <th>
                                <a href="?restore=1&amp;sorting_field=approval&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'approval'}DESC{else}ASC{/if}&amp;users_per_page={$users_per_page}{if $online==1}&amp;online=1{/if}" onClick="return setParam('sorting_field', 'approval', 'sorting_order', '{if $sorting_order == 'ASC' && $sorting_field == 'approval'}DESC{else}ASC{/if}')">[[Approval Status]]</a>
                                {if $sorting_field == 'approval'}{if $sorting_order == 'DESC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                            </th>
                        	{/if}
                        </tr>
                    </thead>
                    {foreach from=$found_users item=found_user name=users_block}
                        <tr class="{cycle values = 'evenrow,oddrow'}">
                            <td><b>{$found_user.sid}</b></td>
                            <td><a href="{$GLOBALS.site_url}/choose-user/?user_sid={$found_user.sid}" onClick="if (location.href.indexOf('manage-invoices')>0){ldelim}return chooseCustomer('{$found_user.sid}'); {rdelim} else {ldelim}return chooseUser('{$found_user.username}');{rdelim}" title="Edit"><b>{$found_user.username}{if $found_user.parent_sid}&nbsp;<small>(sub-user)</small>{/if}</b></a></td>
                            {if $userGroupInfo.id == 'Employer'}
                            	<td>{$found_user.CompanyName}</td>
                            {elseif $userGroupInfo.id == 'JobSeeker'}
         						<td>{$found_user.FirstName}</td>
         						<td>{$found_user.LastName}</td>
                            {/if}
                            <!-- for ie -->	<td style="word-break: break-all;"><!-- for firefox--><div style="word-wrap: break-word; width: 130px;">{$found_user.email}</div></td>
                            <td>{if $found_user.products > 0}{$found_user.products}{else}N/A{/if}</td>
                            <td>{$found_user.registration_date}</td>
                            <td>
                                {if $found_user.active == "1"}
                                    [[Active]]
                                {else}
                                    [[Not Active]]
                                {/if}
                            </td>
                            {if $ApproveByAdminChecked}
                                <td>{$found_user.approval}</td>
                            {/if}
                        </tr>
                    {/foreach}
                </table>
            </div>
        </div>
        <div class="box-footer">
            <div class="resultsnumber"></div>
            <div class="pagination">
                {foreach from=$pages item=page}
                    {if $page == $currentPage}
                        <strong>{$page}</strong>
                    {else}
                        {if $page == $totalPages && $currentPage < $totalPages-3} ... {/if}
                        <a href="?page={$page}{if $sorting_field ne null}&amp;sorting_field={$sorting_field}{/if}{if $sorting_order ne null}&amp;sorting_order={$sorting_order}{/if}&amp;users_per_page={$users_per_page}{$searchFields}">{$page}</a>
                        {if $page == 1 && $currentPage > 4} ... {/if}
                    {/if}
                {/foreach}
            </div>
        </div>
    </div>

</form>
